<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title></title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="ProgId" content="VisualStudio.HTML">
		<meta name="Originator" content="Microsoft Visual Studio .NET 7.1">
	</head>
	<body>
		<h1>ASP .NET postprocessing HtmlModule to ensure output is valid XHTML transitional</h1>
		<h2>
			Installation
		</h2>
		<p>
			Run the installer, the assemblies will be added to the Global Assembly Cache
		</p>
		<h2>Configuration</h2>
		<p>
			Add the following to the appropriate sections in a sites web.config to enable 
			filtering:
		</p>
		<pre>
		
	&lt;httpModules&gt;
		&lt;add name="ComplianceFilter" type="ComplianceFilter.ComplianceFilter,ComplianceFilter,Version=1.0.0.0, Culture=neutral, PublicKeyToken=a92106508d9da1f3" /&gt;
	&lt;/httpModules&gt;
	...
	&lt;assemblies&gt;
		&lt;add assembly="ComplianceFilter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a92106508d9da1f3" /&gt;
		&lt;add assembly="MILHTMLParser, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a92106508d9da1f3" /&gt;
	&lt;/assemblies&gt;
		</pre>
		<p>Also need to add the following</p>
	<pre>
		&lt;section name="ComplianceConfig" type="ComplianceFilter.ConfigSectionHandler, ComplianceFilter,Version=1.0.0.0, Culture=neutral, PublicKeyToken=a92106508d9da1f3"/&gt;
	</pre>
	
	<p>And the config section itself</p>
<pre>
&lt;ComplianceConfig&gt;
	&lt;ApplyMCMSRules&gt;true&lt;/ApplyMCMSRules&gt;
	&lt;RemoveControlSpans&gt;true&lt;/RemoveControlSpans&gt;
&lt;/ComplianceConfig&gt;
</pre>

		The HttpModule will intercept all html from the web application, just before it 
		is streamed to the client and perform a number of transformations.
		<h2>Fixes perfomed</h2>
		<h3>Depricated attribtutes</h3>
		<ul>
			<li>
				'onfocusout' attributes removed from all elements.
			</li>
			<li>
				'id' attribute removed from title.
			</li>
			<li>
				'width'/'height' attributes removed from all elements except for table/img.
			</li>
			<li>
				'hspace'/'align' attributes removed from all elements.
			</li>
			<li>
				'name' attribute removed from form tags.
			</li>
			<li>
				'border' removed from img tags, longdesc is subtitued for alt.
			</li>
			<li>
				language="javascript" replaced with type="text/javascript".
			</li>
			<li>
				target="_blank" removed from ILINK specification in immediacy controlled links
			</li>
		</ul>
		<h3>Object ids</h3>
		<ul>
			<li>
				Leading underscores are removed from all id attribute values.
			</li>
			<li>
				Leading underscores removed from all for attribute values.
			</li>
			<li>
				Apostrophes removed from embedded javascript in onfocus attributes
			</li>
		</ul>
		<h3>Misc fixes</h3>
		<ul>
			<li>
				ASP.NET hidden form variables (__VIEWSTATE,__EVENTARGUMENT and __EVENTTARGET) 
				are now wrapped in a div element.
			</li>
			<li>
				Xml namespace processing instructions are removed from body of HTML.
			</li>
			<li>
				Div and anchor termination is enforced as 
				&lt;div&gt;&lt;/div&gt;,&lt;a&gt;&lt;/a&gt; rather than &lt;a/&gt;,&lt;div/&gt;
			</li>
			<li>
				All hrefs are HtmlAttributeEncoded
			</li>
		</ul>
		<h2>Potential issues</h2>
		<p>
			Substitution of ids to remove the leading '_' in javascript is a simple 
			search/replace for '("_' - enough for getelementbyid but may screw up 
			javascript on more complicated sites than richmond though.
			<h4>Processed ASP .NET postback script</h4>
			<pre>
&lt;script type="text/javascript"&gt;
	&lt;!--
	function __doPostBack(eventTarget, eventArgument) {
		var theform = document.getElementById ('aspnetForm');
		theform.__EVENTTARGET.value = "_" + eventTarget.split("$").join(":");
		theform.__EVENTARGUMENT.value = eventArgument;
		theform.submit();
	}
// --&gt;
&lt;/script&gt;
			</pre>
		</p>
		<pre>
	
	</pre>
	</body>
</html>
